package site.luojie.business.code.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import site.luojie.business.code.service.CodeService;
import site.luojie.common.vo.ResultVo;

/**
 * @author jie.luo
 * @since 2020/9/16
 */
@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private CodeService codeService;

    /**
     * 发送验证码
     */
    @GetMapping("/sendVerifyCode")
    public ResultVo<String> sendVerifyCode(@RequestParam(name = "email") String email) {
        codeService.sendVerifyCode(email);
        return ResultVo.ok();
    }

    /**
     * 校验验证码
     */
    @PostMapping("/verifyCodeCheck")
    public ResultVo<Boolean> verifyCodeCheck(@RequestParam(name = "email") String email,
                                             @RequestParam(name = "verifyCode") String verifyCode) {
        return codeService.verifyCodeCheck(email, verifyCode);
    }
}
